package demo;

import java.util.HashSet;

/**
 * @Author liangzai
 * @Description:
 */
public class Traininig {
    // k-avoiding 数组的最小总和
    public int minimumSum(int n, int k) {
        HashSet<Integer> set = new HashSet<>();
        int sum = 0;
        for(int i = 1; ;i++){
            if(i < k && set.contains(k-i)){
                continue;
            }
            set.add(i);
            if(set.size() == n){
                break;
            }
        }
        for (Integer i : set) {
            sum+=i;
        }
        return sum;

    }
}
